package com.lzm.controller;

import com.lzm.pojo.Departments;
import com.lzm.service.departmentsService;
import com.lzm.vo.ResultVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("departments")
@ResponseBody
public class departmentsController {

    @Resource
    private departmentsService departmentsService;

    @RequestMapping(value = "getlist",method = RequestMethod.GET)
    public ResultVo<Departments> getList(){
        List<Departments> list = departmentsService.getList();
        return new ResultVo<>(list);
    }

    @RequestMapping(value = "{id}",method = RequestMethod.GET)
    public ResultVo<Departments> getSecondList(@PathVariable("id")Integer d_id){
        Departments departments = departmentsService.getSecondList(d_id);
        return new ResultVo<>(departments);
    }
}
